package com.rndemo;

import android.util.Log;

import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.views.scroll.ReactScrollView;
import com.huanqiu.patch.MyPatchConfig;

/**
 * ReactNative Patch
 * Created by tiangui on 2018/7/25.
 */
public class RNPatch extends ReactContextBaseJavaModule {

    private static final String TAG = "ReactNative-RNPatch";

    public RNPatch(ReactApplicationContext reactContext) {
        super(reactContext);
    }

    @Override
    public String getName() {
        return "RNPatch";
    }

//    @ReactMethod
//    public void setFlag(int num) {
//        Log.d(TAG, "setFlag(): " + num);
//        ReactScrollView.hqw_contentOffset = num;
//    }

    // Patch_ReactScrollView_20180728 - add by tiangui @ 20180728
    @ReactMethod
    public void setScrollViewContentOffset(int num) { // FIXME： 这里是否应该使用 浮点数
        if (!MyPatchConfig.Patch_ReactScrollView_20180728) {
            Log.w(TAG, "Patch_ReactScrollView_20180728 NOT open");
            return;
        }
        Log.d(TAG, "setScrollViewContentOffset(): " + num);
        ReactScrollView.hqw_contentOffset = num;
    }

}
